package br.com.fiap.test;

import edu.uci.ics.jung.algorithms.layout.CircleLayout;
import edu.uci.ics.jung.algorithms.layout.Layout;
import edu.uci.ics.jung.graph.Graph;
import edu.uci.ics.jung.graph.SparseMultigraph;
import edu.uci.ics.jung.visualization.VisualizationViewer;
import edu.uci.ics.jung.visualization.decorators.ToStringLabeller;

import javax.swing.*;
import java.awt.*;

/**
 * Demonstrates how to use the DefaultModalGraph mouse's key listener to
 * change modes.  This is one additional line of code from
 * InterativeGraphView1.  Usage: type a "t" while the mouse is over the graph
 * for transforming mode and a "p" for picking mode.
 * @author Dr. Greg M. Bernstein
 */
public class InteractiveGraphView2 {
    Graph<String, String> g;
    /** Creates a new instance of SimpleGraphView */
    public InteractiveGraphView2() {
        // Graph<V, E> where V is the type of the vertices and E is the type of the edges
        g = new SparseMultigraph<String, String>();
        // Add some vertices and edges

    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        InteractiveGraphView1 sgv = new InteractiveGraphView1(); // Creates the graph...
        // Layout<V, E>, VisualizationViewer<V,E>
        Layout<Integer, String> layout = new CircleLayout(sgv.g);
        layout.setSize(new Dimension(600,600));
        VisualizationViewer<Integer,String> vv = new VisualizationViewer<Integer,String>(layout);
        vv.setPreferredSize(new Dimension(450,450));
        // Show vertex and edge labels
        vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
        vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller());

        JFrame frame = new JFrame("Interactive Graph View 3");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().add(vv);
        frame.pack();
        frame.setVisible(true);
    }

}